package com.woniuxy.controller;

import com.woniuxy.entity.UserEntity;
import com.woniuxy.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Author: 马宇航
 * @Description: TODO
 * @DateTime: 25/10/23/星期四 10:37
 * @Component: 成都蜗牛学苑
 **/
@RestController
@RequestMapping("/user")
@CrossOrigin
public class UserController {
    @Autowired
    private UserService userService;
    @GetMapping("")
    public List<UserEntity> findAll() {
        return userService.findAll();
    }
    @PostMapping("")
    public UserEntity insert(@RequestBody UserEntity user) {
        return userService.insert(user);
    }
    @GetMapping("/{id}")
    public UserEntity findById(@PathVariable Integer id) {
        return userService.findById(id);
    }
    @DeleteMapping("/{id}")
    public void delete(@PathVariable Integer id) {
        userService.delete(id);
    }
}
